#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<math.h>
int Func(int a)
{
    int tmp = a;
    int x = 0;
    int g = a;
    while (tmp)
    {
        tmp  %= 10;
        x = x * 10 + tmp;
        tmp = g /= 10;
    }
    return x;
}

int CONV(int N, int a)
{
    int tmp = a;
    int x = 0;
    int i = 0;
    while (a)
    {
        tmp %= 10;
        x = x + tmp * pow(N, i);
        tmp = a /= 10;
        i++;
    }
    return x;
}

int IsFunc(int a)
{
    int x = 0;
    int tmp = a;
    int g = a;
    while (tmp)
    {
        tmp %= 10;
        x = x * 10 + tmp;
        tmp = g /= 10;
    }
    if (x == a)
        return 0;
    else
        return 1;
}

int main() {
    int s = 0;
    int n = 0;
    scanf("%d\n", &n);
    scanf("%d", &s);
    s = CONV(n, s);
    int tmp = 0;
    int steps = 0;
    do {
        s = s + Func(s);
        steps++;
        if (steps > 30)
        {
            printf("Impossible!");
            return 0;
        }
    } while (IsFunc(s));
    printf("STEP=%d", steps);

}